// Copyright@ChenChao

#pragma once

#include "CoreMinimal.h"
#include "Character/CCharacter.h"
#include "CPlayerCharacter.generated.h"

struct FInputActionValue;
class UInputAction;
class UInputMappingContext;
class USpringArmComponent;
class UCameraComponent;
/**
 * 
 */
UCLASS()
class CRUNCH_API ACPlayerCharacter : public ACCharacter
{
	GENERATED_BODY()

public:
	ACPlayerCharacter();

	//客户端首次生成实际角色调用
	virtual void PawnClientRestart() override;

	//设置玩家输入组件
	virtual void SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) override;

private:
	
#pragma region Components
	//弹簧臂组件
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Camera", meta = (AllowPrivateAccess = "true"))
	TObjectPtr<USpringArmComponent> CameraBoom;
	
	//跟随摄像机组件
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Camera", meta = (AllowPrivateAccess = "true"))
	TObjectPtr<UCameraComponent> FollowCamera;
	
#pragma endregion

#pragma region Input
	//输入映射上下文
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Input", meta = (AllowPrivateAccess = "true"))
	TObjectPtr<UInputMappingContext> InputContext;

	//输入动作
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Input", meta = (AllowPrivateAccess = "true"))
	TObjectPtr<UInputAction> InputAction_Jump;

	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Input", meta = (AllowPrivateAccess = "true"))
	TObjectPtr<UInputAction> InputAction_Look;

	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Input", meta = (AllowPrivateAccess = "true"))
	TObjectPtr<UInputAction> InputAction_Move;

	//环视输入回调函数
	void HandleLookInput(const FInputActionValue& InputActionValue);
	//移动输入回调函数
	void HandleMoveInput(const FInputActionValue& InputActionValue);

	//向右看的方向
	FVector GetLookRightDir() const;
	//向前看方向
	FVector GetLookForwardDir() const;
	//向前移动方向
	FVector GetMoveForwardDir() const;
	
#pragma endregion

	
};
